<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" >
<head>
    <meta charset="UTF-8">
    <title>注册页面</title>
    <script src="/js/axios.js" ></script>
    <script src="/js/vue.js" ></script>
    <link href="/el/element.css" rel="stylesheet"  type="text/css"/>
    <script src="/el/element.js"></script>
    <script src="/js/wangEditor.js"></script>
</head>
<body>
<div id="app">
    <p>
        <el-link  type="primary" href="/api/public/go2Index">返回主页</el-link>
    </p>
     <h2 style="color:red;">注册</h2>
    <el-form :model="user"label-width="120px" label-position="left">
        <el-form-item label="请输入账号" prop="username" >
            <el-input v-model="user.username"></el-input>
        </el-form-item>
        <el-form-item label="请输入密码" prop="password/">
            <el-input v-model="user.password"></el-input>
        </el-form-item>
        <el-form-item label="请输入用户名" prop="nickname/">
            <el-input v-model="user.nickname"></el-input>
        </el-form-item>
        <el-button v-on:click="goRegister()"
                   type="primary">注册</el-button>
    </el-form>
</div>

</body>
<script>
    new Vue({
        el:"#app",
        data:{
            user:{
                username:'',
                password:'',
                nickname:'',
            },
        },
        methods:{
            goRegister(){
                this.register =false
                console.log(this.user)
                var that =this
                axios.post("/api/public/addUser",this.user).then(
                    function (resq) {
                        console.log(resq.data)
                        that.$message({
                            showClose: true,
                            offset: 100,
                            message: resq.data.msg,
                            type: 'success'
                        });
                        top.location.href="/api/public/go2Login"
                    }
                )
            }
        },
        mounted(){

        }
    })



</script>
</html>